package org.xpandaframework.base.controller;

import java.io.Serializable;

/**
 * <p>
 * CopyRright (c)2008-2014: Camelot
 * <p>
 * Project: xpandaframework
 * <p>
 * Module ID: <模块类编号可以引用系统设计中的类编号>
 * <p>
 * Comments: ajax请求处理结果返回
 * <p>
 * JDK version used: JDK1.7
 * <p>
 * NameSpace: org.xpandaframework.base.controller.ControllerResult.java
 * <p>
 * Author: Angus
 * <p>
 * Create Date: 2014年11月25日
 * <p>
 * Modified By: <修改人中文名或拼音缩写>
 * <p>
 * Modified Date: <修改日期>
 * <p>
 * Why & What is modified: <修改原因描述>
 * <p>
 * Version: v1.0
 */
public class ControllerResult implements Serializable {

  /**
   * @fields serialVersionUID
   */
  private static final long serialVersionUID = 5905715228490291386L;
  /**
   * @fields status 状态信息，正确返回OK，否则返回 ERROR，如果返回ERROR则需要填写Message信息
   */
  private Status status;
  /**
   * @fields record 消息对象
   */
  private Object message;

  /**
   * @Fields content : 内容体
   */
  private Object content;

  public ControllerResult() {
    super();
  }

  /**
   * @param status
   *          状态
   * @param message
   *          消息
   * @param content
   *          结果集
   */
  public ControllerResult(Status status, Object message, Object content) {
    this.status = status;
    this.message = message;
    this.content = content;
  }

  /**
   * 结果类型信息
   */
  public enum Status {
    SUCCESS, FAIL
  }

  /**
   * 添加成功结果信息
   * 
   * @param message 成功信息
   * @param content 内容
   * @throws Exception
   */
  public void addSuccess(Object message, Object content) {
    this.message = message;
    this.status = Status.SUCCESS;
    this.content = content;
  }

  /**
   * 添加错误消息
   * 
   * @param message
   */
  public void addFail(Object message, Object content) {
    this.message = message;
    this.status = Status.FAIL;
    this.content = content;
  }

  public void addDefultSuccess(Object content) {
    this.message = "操作成功！";
    this.status = Status.SUCCESS;
    this.content = content;
  }

  public void addDefultFail(Object content) {
    this.message = "操作失败";
    this.status = Status.FAIL;
    this.content = content;
  }

  public Status getStatus() {
    return this.status;
  }

  public void setStatus(Status status) {
    this.status = status;
  }

  public Object getMessage() {
    return this.message;
  }

  public void setMessage(Object message) {
    this.message = message;
  }

  public Object getContent() {
    return this.content;
  }

  public void setContent(Object content) {
    this.content = content;
  }

}
